<?php

namespace App\Http\Controllers\Auth;

use App\Http\Controllers\Controller;
use App\Http\Requests\Auth\CodeRequest;
use Illuminate\Http\Request;

class ForgetController extends Controller
{
    public function forget(CodeRequest $request){
        //验证code
        if (cache('email_code_'.$request->email)!=$request->code){
            return $this->response->errorBadRequest('邮箱或者验证码错误');
        }
        $user=auth('api')->user();
        $user->email = $request->email;
        $user->save();
        return $this->response->noContent();
    }
}
